package com.wfs.myapp.controller;

import com.wfs.myapp.common.ApiResult;
import com.wfs.myapp.remote.wx.WxRemoteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;

@RestController
@RequestMapping("/wx")
@Api(value = "微信API", tags = "微信API")
@Slf4j
public class WxApiController {

    @Autowired
    private WxRemoteService remoteService;

    @GetMapping("/msg/send")
    @ApiOperation(value = "消息推送")
    public String msgSend(@RequestParam("signature") String signature,
                                     @RequestParam("echostr") String echostr,
                                     @RequestParam("timestamp") String timestamp,
                                     @RequestParam("nonce") String nonce,
                                     HttpServletRequest request
                                     ) {
        return remoteService.msgSend(signature, echostr, timestamp, nonce);
    }

    @GetMapping("/scanqrcode")
    @ApiOperation(value = "识别二维码")
    public String scanqrcode(HttpServletRequest request) throws UnsupportedEncodingException {
        return remoteService.scanQrCode();
    }

}
